/*
 * Creature.h
 *
 *  Created on: Nov 14, 2009
 *      Author: OD
 */

#ifndef CREATURE_H_
#define CREATURE_H_
#include "Direction.h"
#include "Species.h"
#include <cstdlib>


/**
* Class contains instance data for the monsters on the board
*/

class Creature{
	private:
		Species* mySpecies;//type of species
		//Direction myDirection;//direction of creature
		int myDirection;
		int myPC;//counter of creature

	public:
		
		Creature(){

			mySpecies=0;
		}
		
		Creature(Species* species, int direction){
	        	mySpecies = species;
	        	myDirection = direction;
			myPC = 0;}
		/**
		* get species
		* @return pointer to the species instance
		*/
		Species* getSpecies(){
			return mySpecies;
		}

		/**
		* set random stuff
		* @return pointer to the species instance
		*/
		void setRand(Species* s){
			mySpecies=s;
			myDirection=std::rand()%4;
			myPC=0;
		}

		/**
		* returns direction
		* @return direction
		*/
		int getDirection(){
			return myDirection;
		}

		/**
		* returns program counter
		* @return program counter
		*/
		int& getPC(){
			return myPC;
		}
		/**
		* Set program counter
		* @param c New program counter
		*/
		void setPC(int c){
			myPC = c;
		}

		/**
		* Infects this creature into Species s
		* @param s New Species
		*/
		void infect(Species* s){
			mySpecies=s;
			myPC=0;
		}
		
		/**
		* turns creature left or right
		* @param x 1 turn left else turn right
		*/
		void setDirection(int x){//set creature's direction
			
	    		if(x==1){//1 is left
                           if(myDirection == 1)
                                   myDirection = 0;
                           else if(myDirection == 0)
                                   myDirection = 3;
                           else if(myDirection == 3)
                                   myDirection = 2;
                           else
                                   myDirection = 1;
                   }else{//2 is right
                           if(myDirection == 1)
                                   myDirection =2;
                           else if(myDirection == 2)
                                   myDirection = 3;
                           else if(myDirection == 3)
                                   myDirection = 0;
                           else
                                   myDirection = 1;
                   }
	    }


};

#endif /* CREATURE_H_ */
